// Copyright@ChenChao


#include "Characters/RPG_AnimInstance.h"

#include "Characters/RPG_CharacterBase.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Kismet/KismetMathLibrary.h"

void URPG_AnimInstance::NativeInitializeAnimation()
{
	Super::NativeInitializeAnimation();
	
	RPG_Character = Cast<ARPG_CharacterBase>(TryGetPawnOwner());
	if (RPG_Character == nullptr) return;
	RPG_CharacterMovement = RPG_Character->GetCharacterMovement();
	
}

void URPG_AnimInstance::NativeUpdateAnimation(const float DeltaSeconds)
{
	Super::NativeUpdateAnimation(DeltaSeconds);

	if (RPG_CharacterMovement == nullptr) return;
	// GroundSpeed = RPG_CharacterMovement->Velocity.Length();
	GroundSpeed = UKismetMathLibrary::VSizeXY(RPG_CharacterMovement->Velocity);
	IsFalling = RPG_CharacterMovement->IsFalling();
	/*角色状态*/
	E_CharacterState = RPG_Character->GetCharacterState();
}
